﻿namespace Rosieks.Web.Flow
{
    using System.Web.Routing;

    public class ClearWebflowPolicy : ICheckStatePolicy
    {
        public bool IsCurrentStateValid(WebflowContext webflowContext, RequestContext requestContext, out RouteData routeData)
        {
            routeData = null;

            if (!webflowContext.CurrentState.IsRequestedStep(requestContext))
            {
                webflowContext.Complete();

                routeData = webflowContext.Webflow.FirstState.RouteData;

                return false;
            }

            return true;
        }
    }
}
